<?php
namespace frontend\controllers;

use app\models\Apply;
use app\models\Payinfo;
use Yii;
use yii\web\Controller;


/**
 * Text controller
 */
class PaymentController extends Controller
{
    public $enableCsrfValidation = false;
    //（用户）使用额度支付后，处理信息
    public function actionQuotahandle()
    {
        if(Yii::$app->request->isPost){
            $post=Yii::$app->request->post();
            if(!empty($post['yid'])){
                $model=new Payinfo();
                $res=$model->quotapay($post);
                if($res['code']==200){
                    return json_encode(['code' => 200, 'message' => '处理成功！','data'=>'']);
                }else{
                    return json_encode(['code' => 404, 'message' => '处理失败！','data'=>'']);
                }
            }else{
                return json_encode(['code' => 401, 'message' => '参数缺失！','data'=>'']);
            }

        }
    }
    //（资方）代付后，处理信息
    public function actionRepayhandle()
    {
        if(Yii::$app->request->isPost){
            $post=Yii::$app->request->post();
            if(!empty($post['pid'])){
                $model=new Payinfo();
                $res=$model->repaypay($post);
                if($res['code']==200){
                    return json_encode(['code' => 200, 'message' => '处理成功！','data'=>'']);
                }else{
                    return json_encode(['code' => 404, 'message' => '处理失败！','data'=>'']);
                }
            }else{
                return json_encode(['code' => 401, 'message' => '参数缺失！','data'=>'']);
            }

        }
    }


}
